/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { getChildrenArea } from '@/services/YzBond';

function loadData(selectedOptions: any, options: any[], setOptions: Function) {
  const targetOption = selectedOptions[selectedOptions.length - 1];
  targetOption.loading = true;
  const isLeaf = selectedOptions.length > 2;
  getChildrenArea({ id: targetOption.value }, isLeaf).then((data) => {
    targetOption.loading = false;
    targetOption.children = data;
    setOptions([...options]);
  });
}

function getAddress(params: any, setOptions: Function) {
  getChildrenArea(params).then((data: any) => {
    setOptions(data);
  });
}

export { loadData, getAddress };
